//
//  ExperViewController.m
//  PrintPort
//
//  Created by hy002 on 2018/1/3.
//  Copyright © 2018年 HUAYU. All rights reserved.
//

#import "ExperViewController.h"

static NSString *cellPath = @"ExperCell";
@interface ExperViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong)UITableView *tableview;


@end

@implementation ExperViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatUI];
}

- (void)creatUI
{
    self.navigationController.navigationBar.translucent = NO;
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"体验馆";
    self.tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-STA_NAV_HEIGHT) style:UITableViewStylePlain];
    _tableview.delegate = self;
    _tableview.dataSource = self;
    _tableview.backgroundColor = BacksColor;
    [_tableview setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
    [self.view addSubview:_tableview];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _experArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellPath];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (_experArray.count > 0)
    {
        ExperienceModel *model = _experArray[indexPath.row];
        UILabel *titLab = [ZCControl createLabelWithFrame:CGRectMake(15*displaywidth, 5*displaywidth, SCREEN_WIDTH-130*displaywidth, 35*displaywidth) Font:14.0 Text:model.nickname Color:RGB(77, 77, 77)];
        titLab.lineBreakMode = NSLineBreakByTruncatingTail;
        [cell.contentView addSubview:titLab];
        UILabel *areaLab = [ZCControl createLabelWithFrame:CGRectMake(SCREEN_WIDTH-115*displaywidth, 5*displaywidth, 100*displaywidth, 35*displaywidth) Font:12.0 Text:model.districtText Color:RGB(128, 128, 128)];
        areaLab.textAlignment = NSTextAlignmentRight;
        [cell.contentView addSubview:areaLab];
        
        
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    ExperienceModel *model = _experArray[indexPath.row];
    if (self.closeBlock != nil)
    {
        self.closeBlock(model);
        [self.navigationController popViewControllerAnimated:YES];
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 45*displaywidth;
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
